#ifndef LAYER_H
#define LAYER_H

#include <vector>
#include <memory>

#include "state.h"
#include "../entities/drawable.h"
#include "../entities/entity.h"
#include "../entities/player.h"
#include "../entities/button.h"
#include "SDL2/SDL.h"

struct Layer {
	int rank;
	std::unique_ptr<Player> player;
	std::vector<Entity> entities;
	std::vector<Drawable> drawables;
	std::vector<Button> buttons;

	Layer(int rank);

	void cleanup();
	void update(State& state, std::vector<Layer>& layers, bool pressed_keys[], int& camera_x, int& camera_y);
	void render(SDL_Renderer *renderer);

	inline void register_player(RenderData render_data)
	{
		if (player != nullptr)
			SDL_Log("layer already has player registered\n");

		player = std::make_unique<Player>(Player(render_data));
		player_set = true;
	}

	inline bool has_player()
	{
		return player_set;
	}
private:
	bool player_set = 0;
};

#endif